home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 07 - 1991 / MacTutor Live! SF 91 / GIFfy / MyGIF.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-01-07  |  1.7 KB  |  96 lines  |  [TEXT/MPS ]

  1. #include    <memory.h>
  2. #include    <fonts.h>
  3. #include    <textedit.h>
  4. #include    <windows.h>
  5. #include    <menus.h>
  6. #include    <dialogs.h>
  7. #include    <palette.h>
  8. #include    <quickdraw.h>
  9. #include    <packages.h>
  10. #include    <desk.h>
  11. #include    "Gif.h"
  12.  
  13. extern    CWindowPtr        palWindow;
  14. extern    CWindowPtr        gifWindow;
  15. extern    PaletteHandle    thePalette;
  16.  
  17. MainLoop()
  18. {
  19.   Point            where = {80,80};
  20.   SFTypeList    typeList;
  21.   SFReply        reply;
  22.   Boolean        done = FALSE;
  23.   Boolean        result;
  24.   EventRecord    theEvent;
  25.   WindowPtr        whichWindow;
  26.  
  27.   typeList[0] = 'GIFf';
  28.   typeList[1] = 'TEXT';
  29.   
  30.   do {
  31.     SFGetFile(where,'',NULL,2,&typeList,NIL,&reply);
  32.     if (reply.good) {
  33.        result = ProcessGIF(reply.fName,reply.vRefNum);
  34.        if (result) {
  35.             do {
  36.             SystemTask();
  37.             if (GetNextEvent(everyEvent, &theEvent)) {
  38.               switch (theEvent.what) {
  39.               case mouseDown:
  40.                 switch (FindWindow(theEvent.where, &whichWindow)) {
  41.                   case inGoAway:
  42.                     if (TrackGoAway(whichWindow, theEvent.where)) {
  43.                       done = TRUE;
  44.                     };
  45.                     break;
  46.                   default: ;
  47.                   }
  48.                 case keyDown:
  49.                 case autoKey: {
  50.                   register char    theChar;
  51.                   theChar = theEvent.message & charCodeMask;
  52.                   if ( (theEvent.modifiers & cmdKey) != 0) {
  53.                     if (theChar == 'W' || theChar == 'w') {
  54.                       done = TRUE;
  55.                     }
  56.                   }
  57.                 }
  58.                 default: ;
  59.               }
  60.             }
  61.           } while (!done);
  62.         done = FALSE;
  63.         DisposeWindow((WindowPtr) palWindow);
  64.         DisposeWindow((WindowPtr) gifWindow);
  65.         if (thePalette) {
  66.             DisposePalette(thePalette);
  67.         }
  68.       }
  69.     }
  70.   } while (reply.good);
  71. }
  72.  
  73. SetupMacintosh()
  74. {
  75.   MaxApplZone();
  76.   MoreMasters();
  77.   MoreMasters();
  78.   MoreMasters();
  79.   MoreMasters();
  80.  
  81.   InitGraf(&qd.thePort);
  82.   InitFonts();
  83.   InitWindows();
  84.   InitMenus();
  85.   TEInit();
  86.   InitDialogs(NIL);
  87. }
  88.  
  89. main()
  90. {
  91.   SetupMacintosh();
  92.   InitCursor();
  93.   
  94.   MainLoop();
  95. }
  96.